<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<% String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %>
<%@ taglib uri="/WEB-INF/tld/fmt.tld" prefix="fmt" %>
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>拖车渠道信息</title>
    <jsp:include page="../../import.jsp" flush="true" />
    <%--<jsp:include page="assParkCommon.jsp" flush="true" /><!-- 时间格式转换 -->--%>
</head>
<body class="iframeBody">
<div class="Wrapper">
    <div>
        <div id="pageInTab" class="pageInTab">
            <div tabid="baseInfo" title="基本信息" lselected="true">
                <form id="assTrailCarChnFormSet">
            <div class="fieldset1 tabel_col clearFix">
                <div class="caption">
                    <span class="title">拖车渠道信息</span>
                </div>
                <div class="fieldBox col_33 clearFix">
                    <div class="label">渠道类型</div>
                    <div class="field">
                        <select name="channelTypeCd" id="channelTypeCd" data-value="${assTrailCarChannelVO.channelTypeCd}" validate ="{required:true,select:true}" onchange="cstTypCdFun(this.value);">
                            <option value=" " checked >请选择</option>
                            <c:forEach items="${cstTypCdList }" var="kv">
                                <option value="${kv.key }">${kv.value }</option>
                            </c:forEach>
                        </select>
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">渠道备案省</div>
                    <div class="field">
                        <select name="recordPrCd" id="recordPrCd" data-value="${assTrailCarChannelVO.recordPrCd}" validate ="{required:true,select:true}">
                            <option value="" seleted>请选择</option>
                            <c:forEach items="${provinceKVList}" var="province">
                                <option value="${province.key }">${province.value }</option>
                            </c:forEach>
                        </select>
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">渠道名称</div>
                    <div class="field">
                        <input name="channelNm" id="channelNm" value="${assTrailCarChannelVO.channelNm}" readonly type="text" class="ui-textbox" validate="{required:true}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">身份证号</div>
                    <div class="field">
                        <input name="idNo" id="idNo" type="text" class="ui-textbox" value="${assTrailCarChannelVO.idNo}" readonly validate="{required:true, idcardno:true}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">联系电话</div>
                    <div class="field">
                        <input name="mp" id="mp" type="text" class="ui-textbox" value="${assTrailCarChannelVO.mp}" readonly validate="{required:true, mobileAndFixedPhone:true}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">邮箱</div>
                    <div class="field">
                        <input name="email" id="email" type="text" class="ui-textbox" value="${assTrailCarChannelVO.email}" readonly validate="{email:true}">
                    </div>
                </div>
                <div class="fieldBox col_33" id="succDiv">
                    <div class="label">统一社会信用代码</div>
                    <div class="field">
                        <input name="succ" id="succ" type="text" class="ui-textbox" value="${assTrailCarChannelVO.succ}" readonly validate="{required:true, alnum:true}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_33" id="corpRepDiv">
                    <div class="label">法人代表</div>
                    <div class="field">
                        <input name="corpRep" id="corpRep" type="text" class="ui-textbox" readonly value="${assTrailCarChannelVO.corpRep}" validate="{required:true}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">日常所在地</div>
                    <div class="field">
                        <input name="dailyAddr" id="dailyAddr" type="text" class="ui-textbox" readonly value="${assTrailCarChannelVO.dailyAddr}" validate="{required:true}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">成立日期</div>
                    <div class="field">
                        <input name="regDt" id="regDt" type="text" class="ui-datepicker" readonly value="" validate="{required:true}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_33" id="regCapAmtDiv">
                    <div class="label">注册资本(元)</div>
                    <div class="field">
                        <input name="regCapAmt" id="regCapAmt" type="text" class="ui-textbox" readonly value="${assTrailCarChannelVO.regCapAmt}" validate="{number:true}">
                    </div>
                </div>
                <div class="fieldBox col_33" id="expDtDiv">
                    <div class="label">营业期限</div>
                    <div class="field">
                        <input name="expDt" id="expDt" type="text" class="ui-datepicker" readonly value="" >
                    </div>
                </div>
                <div class="fieldBox col_100">
                    <div class="label">地址</div>
                    <div class="field">
                        <input name="addr" id="addr" type="text" class="ui-textbox" readonly value="${assTrailCarChannelVO.addr}" validate="{required:true}">
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_33">
                    <div class="label">合作模式</div>
                    <div class="field">
                        <input type="text" id="coopTypCd" name="coopTypCd" validate="{required:true}" ltype="combobox"
                               data-value="${assTrailCarChannelVO.coopTypCd}" placeholder="请选择"/>
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_66">
                    <div class="label">地区</div>
                    <div class="field">
                        <input type="text" id="rgnCd" name="rgnCd" validate="{required:true}" ltype="combobox"
                               data-value="${assTrailCarChannelVO.rgnCd}" readonly placeholder="请选择"/>
                        <span class="requiredSymbol">*</span>
                    </div>
                </div>
                <div class="fieldBox col_100" id="fileModify">
                    <div class="label">资料</div>
                    <div class="field">
                        <jsp:include page="../../system/sysUlFilesRec/sysUlFileRecListDetail.jsp" flush="true" >
                            <jsp:param name="pkId" value="${id }"/>
                            <jsp:param name="tabNm" value="ASS_TRAIL_CAR_CHN"/>
                        </jsp:include>
                    </div>
                </div>
                <div class="fieldBox col_100_auto">
                    <div class="label">备案信息</div>
                    <div class="field">
                    <textarea name="recordInfo1" id="recordInfo1" class="ui-textarea l-textarea" cols="100" rows="6"
                              style="width:80%;" value="${insChnOpenSettingVO.settingRem}"
                              validate="{required:false,maxlength:180}" disabled >${assTrailCarChannelVO.recordInfo}
                    </textarea>
                    </div>
                </div>
                <!-- 隐藏主键、系统代码(融资租赁系统) -->
                <div class="fieldBox col_100" style="display:none;">
                    <div class="field">
                        <input name="cId" id="cId" type="text" class="ui-textbox" value="${id}">
                    </div>
                </div>
            </div>

            <div class="btnsBox">
                <%--<span id="saveAssParkingInfoBtn" class="sq-button sq-button-round" onclick="saveAssTrailCarChnInfo()">保存</span>--%>
                <%--<span id="closeBtn" class="sq-button sq-button-round" onclick="Remove_navTab()">关闭</span>--%>
                <input name="chnId" id="chnId" type="hidden" value="${id}">
            </div>
        </form>
            </div>
            <div tabid="bankAcc" title="银行账号">
                <iframe frameborder="0" src=""></iframe>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript">
    var grid = null;
    var pageInApp = {};
    var loadedTabs = [];
    //加载
    $(function() {

        //标签页
        pageInTab = $("#pageInTab").ligerTab({
            height: 'auto',
            contextmenu: false,
            minIframeHeight: GET_minIframeHeight(),
            onBeforeSelectTabItem: function (tabid) {
                var chnId = $("#chnId").val();
                if(tabid!="baseInfo"){
                    if(!chnId){
                        top.$.ligerDialog.SQalert({content: "请确认拖车渠道信息已存在", SQ_type: "warning"});
                        return false;
                    }
                }
            },
            onAfterSelectTabItem: function (tabid) {
                if (loadedTabs.indexOf(tabid) < 0) {
                    var chnId = $("#chnId").val();
                    if(tabid!="tabA"){
                        if(!chnId){
                            top.$.ligerDialog.SQalert({content: "请确认经销商基本信息已存在", SQ_type: "warning"});
                            return false;
                        }
                    }
                    loadedTabs.push(tabid);
                    switch (tabid) {
                        case "bankAcc":
                            pageInTab.setTabItemSrc(tabid, "<%=path%>/ass/assChnBankAcc/toListDeatilPage.do?chnId="+chnId);
                            break;
                    }
                }
                SetIframe_height();
            }
        });
        $.extend(true, pageInApp, {
            pageInTab: pageInTab
        });

        $("#regDt").val(renderDate('${assTrailCarChannelVO.regDt}'));//成立时间
        $("#expDt").val(renderDate('${assTrailCarChannelVO.expDt}'));//营业期限
        $("#coopTypCd").ligerComboBox({
            selectBoxWidth: 240,
            selectBoxHeight: 150,
            treeLeafOnly: false, //限制只能选叶节点，父节点不能点击
            valueField: 'key',
            textField: 'value',
            onlyParentNode: true, //只保留树的父节点值
            tree: {
                data:${coopTypCdListJson},
                idFieldName: 'key',
                textFieldName: 'value',
                parentIcon: "none",
                childIcon: "none",
            },
        });

        $("#rgnCd").ligerComboBox({
            selectBoxWidth: 240,
            selectBoxHeight: 150,
            treeLeafOnly: false, //限制只能选叶节点，父节点不能点击
            valueField: 'key',
            textField: 'value',
            onlyParentNode: true, //只保留树的父节点值
            tree: {
                data:${provinceKVListJson},
                idFieldName: 'key',
                textFieldName: 'value',
                parentIcon: "none",
                childIcon: "none",
            },
        });

        initData();//初始化数据 coopTypCd
        cstTypCdFun();
        liger.get("channelTypeCd").setDisabled(false);
        liger.get("recordPrCd").setDisabled(false);
        liger.get("rgnCd").setDisabled(false);
        liger.get("regDt").setDisabled(false);
        liger.get("expDt").setDisabled(false);
        liger.get("coopTypCd").setDisabled(false);

        $("#assTrailCarChnFormSet input").attr("disabled","disabled");


    });
    //初始化数据
    function initData(){
        initForm();//初始化表单
    }
    //初始化表单
    function initForm(){
        $("#assTrailCarChnFormSet").ligerForm({
            validate: true
        });
    };

    function cstTypCdFun() {
        var selectValue = $("#channelTypeCd").val();
        // var value = liger.get("channelTypeCd").getValue();
        if("1" == selectValue){//自然人
            $("#succDiv").css("display","none");
            $("#corpRepDiv").css("display","none");
            $("#regCapAmtDiv").css("display","none");
            $("#expDtDiv").css("display","none");
        }else{
            $("#succDiv").css("display","block");
            $("#corpRepDiv").css("display","block");
            $("#regCapAmtDiv").css("display","block");
            $("#expDtDiv").css("display","block");
        }
    };

    //保存信息
    function saveAssTrailCarChnInfo(){
        var ligerForm = liger.get("assTrailCarChnFormSet");

        //取消输入框验证
        var _channelTypeCd= liger.get("channelTypeCd").getValue();//渠道类型 1：自然人  2：法人
        if (_channelTypeCd == "1") {
            ligerForm.setFieldValidate("succ", {required: false});//社会统一信用代码
            ligerForm.setFieldValidate("corpRep", {required: false});//法人代表
            ligerForm.setFieldValidate("regCapAmt", {required: false});//注册资本
            ligerForm.setFieldValidate("expDt", {required: false});//营业期限
        }

        if (!ligerForm.valid()) {
            $.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }

        //获取ID-为空执行添加,否则修改
        var cId = $("#cId").val();
        var data = ligerForm.getData();//获取表单数据
        data["id"] = cId;
        var fileParams = getUploadResultParams();//获取附件上传的信息
        data["fileParams"] = JSON.stringify(fileParams);
        //默认新增信息
        var url = '<%=path%>/ass/assTrailCarChannel/add.do';
        if(cId){
            url = '<%=path%>/ass/assTrailCarChannel/modify.do';
        }
        var wait_dialog = null;
        $.ajax({
            type: 'post',
            dataType: 'json',
            data: data,
            url: url,
            beforeSend: function(){
                wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
            },
            success:function(msg){
                wait_dialog.close();
                if(msg.success == 1){
                    $.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
                }else{
                    $.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
                }
            }
        });
    }

    //格式化时间
    function renderDate(value) {
        var dateStr = "";
        if (null != value) {
            var date = new Date(value);
            dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
        }
        return dateStr;
    }

</script>
</body>
</html>